<template>
  <div >
    <h1 >内容1-3</h1>
    <div>
      本次体验用时{{this.seconds}}秒
    </div>
    <div>
    哇噢，成绩不错噢~
快去分享给好友炫耀一下~
  </div>
  <button class="btn" @click.stop="goImg">分享给好友</button>

  </div>
</template>

<script>
export default {
  name: 'index',
  data() {
    return {
      minutes:0,
      seconds:0,
    };
  },
created() {
  this.getTime();
},


methods: {
  goImg() {
    this.$router.push({
				path: "/01/register/wx/index5",

			});
  },
  getTime() {
    if (localStorage.getItem('seconds') === null) {
      const endTime = new Date(); // 记录结束时间
      const startTime = new Date(parseInt(localStorage.getItem('startTime')));
      const duration = endTime - startTime; // 计算用时

      // 将用时转换为可读格式，例如小时和分钟
      // this.minutes = Math.floor((duration % 3600000) / 60000);
      this.seconds = Math.floor(((duration % 3600000) % 60000) / 1000);
      localStorage.setItem('seconds', this.seconds);
      // 输出或处理结果
      console.log(`${this.seconds} 秒`);
    } else{
      this.seconds = localStorage.getItem('seconds')
    }


      // 停止计时，只在第一次获取时间后执行

    },

}
}
</script>

<style scoped lang="less">

</style>
